﻿using System;

namespace Quail
{
    /// <summary>
    /// Wraps input@type=image elements
    /// </summary>
    public class WebImage : WebControl
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="WebImage"/> class.
        /// </summary>
        /// <param name="container">The owning WebControlContainer</param>
        /// <param name="selector">The jQuery selector for this control</param>
        public WebImage(WebControlContainer container, string selector)
            : base(container, selector)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="WebImage"/> class.
        /// </summary>
        /// <param name="control">The control.</param>
        public WebImage(WebControl control)
            :base(control)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="WebImage"/> class.
        /// </summary>
        public WebImage()
        {
        }

        /// <summary>
        /// Gets the filename from the src attribute
        /// </summary>
        public string Filename
        {
            get { return System.IO.Path.GetFileName(Src); }
        }

        /// <summary>
        /// Gets the src attrbute
        /// </summary>
        public string Src
        {
            get { return Attr(KnownAttribute.Src); }
        }

        /// <summary>
        /// Gets the link's HREF in absolute form
        /// </summary>
        public string SrcAbsolute
        {
            get { return Attr(KnownAttribute.SrcAbsolute); }
        }

        /// <summary>
        /// Gets the alt attribute
        /// </summary>
        public string Alt
        {
            get { return Attr(KnownAttribute.Alt); }
        }
    }
}
